//============================================================================
// Name        : GreenEyesOffloadingServer.cpp
// Author      : Alessandro Bramati
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<iostream>
#include<arpa/inet.h>
#include<unistd.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<opencv2/opencv.hpp>
#include<opencv2/features2d/features2d.hpp>
#include<opencv2/highgui/highgui.hpp>
#include "Utility.h"
using namespace std;
using namespace cv;
#define BUFLEN 1400

int main()
{
	int type,clientsNumber,overlap,loads,threshold,blocks;
	cout<<"Setting up TCP server...."<<endl;
	cout<<"Clients number (0 to 4):"<<endl;
	cin>>clientsNumber;
	if(clientsNumber>0)
	{
		cout<<"Unicast (0) broadcast (1)"<<endl;
		cin>>type;
		if(type==1)
		{
			cout<<"Blocks:"<<endl;
			cin>>blocks;
		}
		cout<<"Image overlap (%):"<<endl;
		cin>>overlap;
		cout<<"Static loads (0) optimal loads (1):"<<endl;
		cin>>loads;
	}
	else
	{
		type=0;
		overlap=0;
		loads=0;
	}
	cout<<"Threshold: "<<endl;
	cin>>threshold;
	//VideoCapture cap(0);
	//if(!cap.isOpened())  // check if we succeeded
	//	printErrorLog("Camera not working");
	if(type==0)
		unicast(clientsNumber,overlap,loads,threshold);
	else
		broadcast(clientsNumber,overlap,loads,threshold,blocks);
	return 0;
}
